-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[V3] Fix initially-hidden menuItem [mac/win] #4116
base: v3-alpha
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces a hidden menu item labeled "I was hidden" in the Demo submenu and a new toggle menu item to switch its visibility. The toggle action is implemented via an Changes
Possibly related PRs
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
v3/pkg/application/menu_darwin.go (1)
102-104
: Good fix for initially-hidden menu itemsThis change appropriately addresses the issue by ensuring hidden menu items are still created but visually suppressed using
setHidden(true)
. Previously, it appears these items were skipped entirely during menu processing, making them impossible to show later.This implementation allows for dynamic toggling of menu item visibility at runtime, which aligns with the PR objective of fixing initially-hidden menuItems on macOS.
This approach is architecturally sound as it maintains a consistent relationship between the application's menu model and the OS menu representation, regardless of visibility state.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
v3/examples/menu/main.go
(1 hunks)v3/pkg/application/menu_darwin.go
(1 hunks)
🔇 Additional comments (1)
v3/examples/menu/main.go (1)
47-52
: Good demonstration of the hidden menu functionalityThis implementation effectively demonstrates the new functionality:
- Creates a menu item that's initially hidden
- Provides a toggle mechanism to change visibility at runtime
- Uses the
Hidden()
method to check current state and negate itThe example serves as good documentation for how developers should implement this feature in their applications.
One small suggestion to enhance this example even further:
// Hidden menu item that can be unhidden hidden := myMenu.Add("I was hidden").SetHidden(true) myMenu.Add("Toggle hidden menu").OnClick(func(ctx *application.Context) { hidden.SetHidden(!hidden.Hidden()) + // Update the toggle menu text to reflect current state + if hidden.Hidden() { + ctx.ClickedMenuItem().SetLabel("Show hidden menu") + } else { + ctx.ClickedMenuItem().SetLabel("Hide menu item") + } })
Previously, when calling `.SetHidden(false)` on a menu item that was not hidden, a duplicate menu item was created.
5140cc0
to
42c6c2b
Compare
And bring menu_windows into alignment with popupmenu_windows
Previously, when calling `.SetHidden(false)` on a menu item that was not hidden, a duplicate menu item was created.
And bring menu_windows into alignment with popupmenu_windows
…nVS/fix-hidden-menuitem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/src/content/docs/changelog.mdx (1)
78-79
: Changelog Entry for the NewSetMenu()
Feature
This new bullet point clearly documents the addition of theSetMenu()
method on the window. Please verify that:
- The changelog description accurately reflects the implementation and intended usage of
SetMenu()
.- There is consistency across the documentation and examples regarding any platform-specific behaviors (for instance, if there are differences between macOS, Windows, and Linux).
Description
Fixes #4088
This addresses the referenced issue, allowing menu items to be hidden at first, and then shown in response to some other event.
This also fixes a bug on Windows, which caused duplicate menu items to be added when calling
.SetHidden(false)
on a menu item that was not hidden.Type of change
Please select the option that is relevant.
How Has This Been Tested?
I tested this by updating the
menu
example and checking that I can toggle the visibility of the menu item.I tried in windows, but was not able to figure it out. I thought maybe removing the
continue
in the similarprocessMenu
would have an effect, but it did not. In fact commenting out the entireprocessMenu
function body seemed to have no effect. I don't know what's going on there.If you checked Linux, please specify the distro and version.
Test Configuration
Please paste the output of
wails doctor
. If you are unable to run this command, please describe your environment in as much detail as possible.Checklist:
website/src/pages/changelog.mdx
with details of this PRSummary by CodeRabbit
New Features
Documentation